package com.yz.jdd.module.cashier.scanpay.exception;

import android.content.Context;

import com.yz.jdd.widget.CustomDialog;


import rx.Subscription;

/**
 * Created by shibin on 2017/2/27.
 */
public class ExceptionPresenter implements ExceptionContract.Presenter {
    private ExceptionContract.ExceptionView iExceptionView;
    private ExceptionContract.IExceptionModel exceptionModel;
    private Context context;
    public boolean isCanceling;//订单是否已撤销
    private CustomDialog dialog;
    private Subscription cancelSubscription;

    public ExceptionPresenter(Context context, ExceptionContract.ExceptionView iExceptionView) {
        this.context = context;
        this.iExceptionView = iExceptionView;
        exceptionModel = new ExceptionModelImpl(context);
        iExceptionView.setPresenter(this);
        isCanceling = false;
    }

    /**
     * 是否在撤销
     * 判断是否阻塞轮询订单返回的成功结果 避免撤销之后 显示订单支付成功
     *
     * @return
     */
    public boolean isCanceling() {
        return isCanceling;
    }

    /**
     * 设置撤销状态
     *
     * @param iscanceling
     */
    @Override
    public void setCanceling(boolean iscanceling) {
        this.isCanceling = iscanceling;

    }

    @Override
    public void unsubscribeCancel() {
        if (cancelSubscription != null) {
            cancelSubscription.unsubscribe();
            cancelSubscription = null;
        }
    }


}
